{% extends 'base.htm' %}
{% from 'macros.htm' import find_post, make_plural, venue_fmt, name_fmt, comment_fmt, photo_fmt, checkin_badge_fmt %}
{% set title = 'Checkin Details' %}

{% block body %}
<br>

{{ venue_fmt(checkin.venue, lat, lon) }}

<hr>
{% set user = checkin.user %}
<p><img src="{{ user.photo.prefix|e ~ '36x36' ~ user.photo.suffix|e }}" class="usericon, lefticon" alt="">{{ name_fmt(user, button=false) }} 
<a href="http://foursquare.com/user/{{ user.id|e }}/checkin/{{ checkin.id|e }}">checked in</a>
{{ checkin.createdAt|fuzzydelta }}

{% set source = checkin.source %}
{% if source %}
    <br>via <a href="{{ source.url|e }}">{{ source.name|e }}</a>
{% endif %}

{% if checkin.shout %}
    <br>"{{ checkin.shout|e }}"
{% endif %}
<br style="clear:both">

{{ checkin_badge_fmt(checkin) }}

{% set score = checkin.score %}
{% if score %}
    {% for s in score.scores %}
	<p><img src="{{ s.icon|e }}" class="lefticon">
	{{ s.points|e }} points: {{ s.message|e }}
	<br style="clear:both">
    {% endfor %}
{% endif %}
<hr>

<p>-- {{ make_plural(checkin.comments.count, 'comment') }} --

{% for comment in checkin.comments['items'] %}
    {{ comment_fmt(comment, checkin) }}
{% endfor %}

<p>-- {{ make_plural(checkin.photos.count, 'photo') }} --

{% for photo in checkin.photos['items'] %}
    {% call(post) find_post(checkin.posts['items'], photo.id) %}
	{{ photo_fmt(photo, checkin_id = checkin.id, post = post) }}
    {% endcall %}
{% endfor %}

<form style="margin:0; padding:0;" action="/addcomment" method="post">
<input class="inputbox" type="text" name="text" size="15"><br>
<input type="hidden" value="{{ checkin.id|e }}" name="chkid">
<input class="formbutton" type="submit" value="Add comment"><br>
</form>

<br>

<form style="margin:0; padding:0;" enctype="multipart/form-data" action="/addphoto" method="post">
<input class="inputbox" type="file" name="photo"><br>
<input type="hidden" value="{{ checkin.id|e }}" name="chkid">
<input class="formbutton" type="submit" value="Add JPEG photo"><br>
</form>
{% endblock %}

{# vim:set ft=htmldjango tw=0: #}
